package com.gjy.design.strategy.payment;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-11-06 11:11:15
 */
public class ShoppingCart {

    private PaymentStrategy paymentStrategy;

    public void setPaymentStrategy(PaymentStrategy paymentStrategy) {
        this.paymentStrategy = paymentStrategy;
    }

    public boolean checkout(double amount) {
        if (paymentStrategy == null) {
            throw new IllegalStateException("请先设置支付策略！");
        }
        return paymentStrategy.pay(amount);
    }

}
